package org.shiwen.week7;

import java.util.Arrays;

public class CopyArray {
    public static void main(String[] args) {
        int[] a = {1,2,3,4,5,6};
        int[] b = {10,20,30,40,50,60,70};
        //从数组a索引为1的元素开始复制到数组b索引为2的元素中，复制长度为5个元素
        System.arraycopy(a, 1, b, 2, 5);
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(b));

        //将数组a复制到数组x中，长度为5
        int[] x = Arrays.copyOf(a, 5);
        System.out.println(Arrays.toString(a));
        System.out.println(Arrays.toString(x));

        //将数组a索引为1的元素开始复制到数组y索引为0的元素中，复制长度为4个元素
        int[] y = Arrays.copyOfRange(a, 1, 5);
        System.out.println(Arrays.toString(y));

//        Animal animal = new Animal();
//        Cat cat = new Cat();
//        System.out.println(animal instanceof Animal);
//        System.out.println(cat instanceof Animal);
//        System.out.println(animal instanceof Cat);
    }
}
